#include('head.html', {title : '修改密码'})
#if(name==null)
<script>
  window.location="/signin";
</script>
#end
<body class="bg-info dker">
<section id="content" class="m-t-lg wrapper-md animated fadeInUp">
  <div class="container aside-xl">
    <a class="navbar-brand block" href="signin"><span class="h1 font-bold">修改密码</span></a>
    <section class="m-b-lg">
      <br><br>
      <style>
        . {
          width:800px;
          font-family:'黑体';
          margin:50px auto;
          margin: 0%;
          padding: 0%;
        }

        #mm,#yx{
          font-size: 12px;
          color: #FAF5FF;
          padding-left: 20px;
          display: block;
          text-align: center;
        }
        .wrong{
          background:url(/static/images/wrong.png) no-repeat  4px 3px;
          /*border: 1px solid #FFAC91;*/
          border: hidden;
          height:32px;
          line-height:32px;
          color:#FF0000 !important;
        }
        /*.fwrong{*/
          /*border-radius: 500px;*/
          /*border:1px solid red;*/
          /*border-color: transparent;*/
          /*border-width: 0;*/
          /*height: 45px;*/
          /*padding: 10px 16px;*/
          /*font-size: 18px;*/
          /*line-height: 1.33;*/
        /*}*/
        /*.fright{*/
          /*border:1px solid skyblue;*/
          /*border-color: transparent;*/
          /*border-width: 0;*/
          /*height: 45px;*/
          /*padding: 10px 16px;*/
          /*font-size: 18px;*/
          /*line-height: 1.33;*/
          /*border-radius: 500px;*/
        /*}*/
        .right{
          /*color: #5EFF5E !important;*/
          background:url(/static/images/right.png) no-repeat 4px 3px;
          /*border: 1px solid #ACFFAC;*/
          height:32px;
          border: hidden;
          line-height:32px;
        }
        .form-group .default{
          width:200px;
          height:32px;
          line-height:32px;
          color:#999;
        }
      </style>
      <script type="text/javascript">
        function check1() {
            var a=document.getElementById('youxiang').value;
            var re = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            if(!re.test(a)){
                document.getElementById('yx').className="wrong";
                document.getElementById('yx').innerHTML="邮箱输入有误";
            }
            else{
                document.getElementById('yx').className="right";
                document.getElementById('yx').innerHTML="正确";
            }
        }
        function check2() {
            var a=document.getElementById('mima1').value;
            var b=document.getElementById('mima2').value;
            var reg = /^.*[~!@#\$%\^&\*\(\)_+\-=\[\]\{\}\\\|\'\";:,\<\.\>\/\?\s+].*$/;
            var regNumber = /\d+/; //验证0-9的任意数字最少出现1次。
            var regString = /[a-zA-Z]+/; //验证大小写26个字母任意字母最少出现1次。
            if((a==''||a==null)&&(b==''||b==null)){
                document.getElementById('mm').innerHTML="密码不能为空";
                document.getElementById('mm').className="wrong";
                return false;
            }
            else if((a.length<4||a.length>16)&&(b.length<4||b.length>16)){
                document.getElementById('mm').innerHTML="密码长度要大于4个字符并且小于16个字符";
                document.getElementById('mm').className="wrong";
                return false;
            }
            else if((!(regNumber.test(a) && regString.test(a) || reg.test(a)))&&(!(regNumber.test(b) && regString.test(b) || reg.test(b)))){
                document.getElementById('mm').className="wrong";
                document.getElementById('mm').innerHTML="密码中要包含字符、数字.可包含特殊符号！";
                return false;
            }
            else if(a!=b){
                document.getElementById('mm').className="wrong";
                document.getElementById('mm').innerHTML="两次密码不相等！";
                return false;
            }else{
                document.getElementById('mm').className="right";
                document.getElementById('mm').innerHTML="正确";
                return true;
            }

        }
      </script>

      <form action="/updatePassword" method="post">
        <div class="form-group">
          <input type="password" name="oldPassword" placeholder="旧密码" id="mima" onblur="check2()" class="form-control rounded input-lg text-center no-border">
          <br>
        </div>
        <div class="form-group">
          <input type="password" name="newPassword" placeholder="新密码" id="mima1" onblur="check2()" class="form-control rounded input-lg text-center no-border">
          <br>
        </div>
        <div class="form-group">
          <input type="password" name="password" placeholder="确认密码" id="mima2" onblur="check2()" class="form-control rounded input-lg text-center no-border">
          <br>
          <span class="default" id="mm"></span>
        </div>
        <button type="button" id="updatepwd" class="btn btn-lg btn-warning lt b-white b-2x btn-block btn-rounded"><i class="icon-arrow-right pull-right"></i><span class="m-r-n-lg">确认修改</span></button>
        <br>
        <a href="javascript:window.history.back()" class="btn btn-lg btn-info btn-block btn-rounded"><i class="fa  fa-reply-all"></i> 返回</a>
        <div class="line line-dashed"></div>
      </form>
    </section>
  </div>
</section>
#include('footer.html')
#include('js.html')
<script>
  $("#updatepwd").click(function(){
    if(check2()){
      $.ajax({
        url:"/updatePassword",
        dataType:"json",
        type:"post",
        data:$("form").serialize(),
        success:function(result){
          alert(result.tips);
          if(result.success=="1")
             window.location="/signin";
        },
        error:function(result){
            alert("系统繁忙！");
         }
    });
    }
  });
</script>
</body>
</html>